import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import { Camera, Vector3, WebGLRenderer } from "three"

export const initControls = (camera: Camera, renderer: WebGLRenderer, _target: Vector3 = new Vector3(0, 0, 0)) => {


  // 初始化控制器
  const controls = new OrbitControls(camera, renderer.domElement);
  controls.target.set(_target.x, _target.y, _target.z);


  controls.enableDamping = true // 启用阻尼效果，使旋转更加平滑
  controls.dampingFactor = 0.05 // 阻尼系数
  controls.autoRotate = true // 自动旋转
  controls.autoRotate = true
  controls.autoRotateSpeed = 10.0 // 自动旋转速度

  return controls
}
